package com.hbusa.service.service.impl;

import cn.hutool.db.Entity;
import cn.hutool.db.PageResult;
import com.hbusa.dao.impl.UserDaoImpl;
import com.hbusa.dto.TbUser;
import com.hbusa.service.UserService;

import java.sql.SQLException;
import java.util.Map;

/**
 * @author XiaoXin
 * @date 2021/12/24 - 21:12
 */


public class UserServiceImpl implements UserService {
    UserDaoImpl userDao = new UserDaoImpl();
    @Override
    public boolean save(TbUser user) {
        boolean save = userDao.save(user);
        return save;
    }

    @Override
    public boolean modify(TbUser user) throws SQLException {
        boolean modify = userDao.modify(user);
        return modify;
    }

    @Override
    public boolean removeById(int id) {
        return false;
    }

    @Override
    public TbUser queryById(int id) {
        TbUser tbUser = userDao.queryById(id);
        return tbUser;
    }

    @Override
    public TbUser queryByUsernameAndPassword(String username, String password) {
        TbUser tbUser = null;
        try {
            tbUser = userDao.queryByUsernameAndPassword(username, password);
        } catch (SQLException throwables) {
            throwables.printStackTrace();
        }
        return tbUser;
    }

    @Override
    public PageResult<Entity> queryByPage(int pageindex, int pagesize, Map<String, Object> searchMap) {
        return null;
    }
}
